<template>
  <view class="my-body">
    <view class="floor-title">
      <view class="title">
        热门推荐
      </view>
    </view>


    <view class="floor-content">
      <view class="floor-item" v-for="good in goods" :key="good['pid']" @click="toDetailHandler(good)">


        <!-- 产品封面图-->
        <view class="coffee-cover">
          <image :src="good['smallImg']" mode=""></image>
          <view class="hot">
            hot
          </view>
        </view>

        <!-- 产品信息-->
        <view class="coffee-info">

          <!-- 中文名字-->
          <view class="coffee-name">
            {{good['name']}}
          </view>


          <!-- 英文名字-->
          <view class="coffee-name-en">
            {{good['enname']}}
          </view>


          <!-- 价格-->
          <view class="coffee-price">
            ￥{{good['price']}}
          </view>





        </view>
      </view>
    </view>





    <!--    <view @click="moreHandler" class="floor-more">
      加载更多
    </view> -->
  </view>
</template>

<script>
  import {
    req
  } from '../../pages/utils/request/request.js'
  export default {
    name: "MyBody",
    data() {
      return {
        goods: [],
      }
    },
    mounted() {
      this.getGoods()
    },
    methods: {
      toDetailHandler(good) {
        uni.navigateTo({
          url: `/pages/goods_detail/goods_detail?wd=${good.pid}`
        })
      },
      getGoods() {
        req('typeProducts', {
          reqData: {
            key: 'isHot',
            value: 1
          }
        }).then(({
          data: res
        }) => {
          this.goods = res['result']
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  .my-body {
    margin: 0 20rpx;

    .floor-more {
      width: 200rpx;
      margin: 0 auto;
      color: #ccc;
      font-size: 24rpx;
      text-align: center;
      margin-bottom: 20rpx;
    }


    .floor-title {
      background-color: #fff;
      height: 80rpx;
      margin-bottom: 20rpx;
      display: flex;
      align-items: center;

      .title {
        background-color: #0c34ba;
        width: 120rpx;
        height: 50rpx;
        border-top-right-radius: 20rpx;
        color: #fff;
        font-size: 20rpx;
        display: flex;
        justify-content: center;
        align-items: center;
      }

    }

    .floor-content {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;

      .floor-item {
        background-color: #fff;
        padding: 20rpx;
        margin-bottom: 20rpx;
        border-radius: 20rpx;
        box-sizing: border-box;

        .coffee-info {
          margin-top: 20rpx;
          color: #8b7c70;
          font-size: 28rpx;

          .coffee-name {
            font-size: 30rpx;
          }

          .coffee-name-en {
            margin: 5rpx 0;
          }

          .coffee-name,
          .coffee-name-en {
            width: 290rpx;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
          }

          .coffee-price {
            color: #0c34ba;
            margin-top: 20rpx;
            font-weight: bold;
          }
        }

        .coffee-cover {
          height: 300rpx;
          width: 300rpx;
          border-radius: 20rpx;
          overflow: hidden;
          position: relative;

          .hot {
            position: absolute;
            z-index: 10;
            width: 60rpx;
            height: 60rpx;
            top: 0;
            left: 20rpx;
            color: #fff;
            background-color: #0c34ba;
            display: flex;
            align-items: center;
            justify-content: center;
            border-bottom-right-radius: 20rpx;
            border-bottom-left-radius: 20rpx;
          }

          image {
            height: 100%;
            width: 100%;
          }
        }
      }
    }
  }
</style>
